﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace TonyNet4V1
{
	public class ShowMessageAlert
	{
		public ShowMessageAlert()
		{
		}

		public static void ShowError(string strMessage)
		{
			System.Web.HttpContext.Current.Response.Write(strMessage);
		}

		public static void ShowError(System.Web.UI.Page page, string strErrorMessage)
		{
			Literal litMessage = new Literal();

			litMessage.Text = "<Script Language='JavaScript'>window.alert('" + "错误" +strErrorMessage + System.IO.Path.GetFileName(page.Request.Path).ToString() + "');</script>";
			page.Controls.Add(litMessage);
		}

		public static void ShowMessage(string strMsg)
		{
			System.Web.HttpContext.Current.Response.Write("<Script Language='JavaScript'>window.alert('" + strMsg + "');</script>");
		}

		public static void ShowMessage(System.Web.UI.Page page, string strMsg)
		{
			//page.Response.Write("<Script Language='JavaScript'>window.alert('" + strMsg + "');</script>");
			Literal litMessage = new Literal();

			litMessage.Text = "<Script Language='JavaScript'>window.alert('" + strMsg + "');</script>";
			page.Controls.Add(litMessage);
		}

		public static void ShowMessage(string strMsg, string Url)
		{
			System.Web.HttpContext.Current.Response.Write("<Script Language='JavaScript'>window.alert('" + strMsg + "');window.location.href ='" + Url + "'</script>");
		}

		public static void ShowMessage(System.Web.UI.Page page, string strMsg, string Url)
		{
			page.Response.Write("<Script Language='JavaScript'>window.alert('" + strMsg + "');window.location.href ='" + Url + "'</script>");
		}

		public static void ShowConfirm(string strMsg, string strUrl_Yes, string strUrl_No)
		{
			System.Web.HttpContext.Current.Response.Write("<Script Language='JavaScript'>if ( window.confirm('" + strMsg + "')) {  window.location.href='" + strUrl_Yes + "' } else {window.location.href='" + strUrl_No + "' };</script>");
		}
	}
}
